package com.movitech.mobile.task;

import com.movitech.mobile.cz.base.purchase.service.SAbutmentLogsService;
import com.movitech.mobile.cz.base.sys.service.SCompanyService;
import com.movitech.mobile.cz.base.sys.service.SProjectService;
import com.movitech.mobile.cz.base.sys.service.SRegionalCompanyService;
import com.movitech.mobile.cz.base.sys.service.SysUserService;
import com.movitech.mobile.mq.RabbitmqConllection;
import com.movitech.mobile.mq.RabbitmqProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 供方信息同步至成本系统
 *
 * @author luodz
 * @version 1.0.0
 * @description 供方信息同步至成本系统MQ
 * @createTime 2023/04/11
 */
@Component
public class SupplierInfoSynRabbitMQProducer implements RabbitmqProducer {

    RabbitmqConllection rabbitmqConllection = null;
    /**
     * MQ服务地址
     */
    @Value("${mqserver.calibrationbid.url}")
    private String MQ_SERVER_URL;

    /**
     * MQ服务密码
     */
    @Value("${mqserver.calibrationbid.port}")
    private String MQ_SERVER_PORT;

    /**
     * MQ服务账号
     */
    @Value("${mqserver.calibrationbid.user}")
    private String MQ_SERVER_USER;

    /**
     * MQ服务密码
     */
    @Value("${mqserver.calibrationbid.password}")
    private String MQ_SERVER_PASSWORD;

    @Value("${mqserver.calibrationbid.queuesupplier2code}")
    private String MQ_QUEUE_NAME;

    @Autowired
    SysUserService sysUserService;
    @Autowired
    SRegionalCompanyService sRegionalCompanyService;
    @Autowired
    SCompanyService sCompanyService;
    @Autowired
    SProjectService sProjectService;
    @Autowired
    @Qualifier("sAbutmentLogsService")
    private SAbutmentLogsService sAbutmentLogsService;

    @Override
    public void init() {
        rabbitmqConllection = RabbitmqConllection
                .instance(MQ_SERVER_URL,
                        MQ_SERVER_PORT,
                        MQ_SERVER_USER,
                        MQ_SERVER_PASSWORD);
    }

    @Override
    public boolean producer(String data) {
        System.out.println("推送数据：======》" + data);
        rabbitmqConllection.producer(MQ_QUEUE_NAME, this, data);
        return false;
    }

    @Override
    public void error(String pushData, Exception ex) {

    }
}
